//
//  LGSError.h
//  LogicSim
//
//  Created by Jeremy Pereira on 04/04/2012.
//  Copyright (c) 2012 Jeremy Pereira. All rights reserved.
//

/*!
 *  @file LGSError.h
 *  @brief Conveinience wrapper for NSError
 *  @author Jeremy Pereira
 */

#import <Cocoa/Cocoa.h>

/*!
 *  @brief Error domain for errors specific to this application.
 */
extern NSString* const LGS_ERROR_DOMAIN;

/*!
 *  @brief Error codes for the LGS_ERROR_DOMAIN.
 */
enum LGSErrorCode
{
    /*!
     *  @brief No error.
     */
  	LGS_ERR_NONE = 0,
    /*!
     *  @brief failure to deserialise JSON.
     *
     *  This error code is used whenever there is something wrong with a JSON
     *  file that has been attempted to be deserialised.  Note that malformed 
     *  JSON strings are not included, this pertains to the generated object 
     *  graph being incorrect, e.g. missing ids etc.
     */
    LGS_ERR_DESERIALISATION_FAILURE,
};

/*!
 *  @brief exception name for unimplemented method exceptions
 */
extern NSString* const LGS_METHOD_UNIMPLEMENTED;

/*!
 *  @brief Convenience class for creating errors.
 */
@interface LGSError : NSError

/*!
 *  @brief Creates a deserialisation error.
 *
 *  The deserialisation error is used whenever a document cannot be read if
 *  it contains logiclly inconsistent JSON.
 *  @param reason A localised string describing the reason for the error.
 *  @return An NSError or an instance of a subclass.
 */
+(NSError*) deserialisationFailureReason: (NSString*) reason;

/*!
 *  @brief Ceates an invalid connection error.
 *
 *  Connection strings are in the form of node.connection where connection is
 *  either an input or an output.  This error is raised if a string is not in
 *  that form or the node or the input/output does not exist.
 *  @param connectionString The connection string that caused the error.
 *  @return an NSError.
 */
+(NSError*) invalidConnection: (NSString*) connectionString;

@end
